import json

if __name__ == '__main__':
    list_path = "/home/isia535/hyx/fewshot_tumor_detection/data/custom/all.txt"
    # list_dataset = ListDataset(list_path=list_path)
    # print(list_dataset[0])
    label_set = set()
    path = []
    with open(list_path, "r") as file:
        data_files = file.readlines()
        for index in range(len(data_files)):
            pack = data_files[index].rstrip().split(',')
            label, annotation_path, img_path = pack[0], pack[-2], pack[-1]
            if label not in label_set:
                label_set.add(label)
                path.append((label, annotation_path, img_path))
    label_dict = {k: v for v, k in enumerate(sorted(list(label_set)))}
    print(label_dict)
    # with open('label_dict.json', 'w') as target:
    #     target.write(json.dumps(label_dict))
    # print(path)
    # with open('support.json', 'w') as target:
    #     target.write(json.dumps(path))
    